package com.google.androidcamp.session4.reader;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class ReaderActivity extends Activity {
    private TextView mNoteText;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mNoteText = (TextView) findViewById(R.id.note_content);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Cursor noteCursor = getContentResolver().query(Uri.parse("content://com.google.androidcamp/note"),
            null, null, null, null);
        String savedText = "[NOTHING]";
        if (noteCursor.moveToFirst()) {
            int noteColIndex = noteCursor.getColumnIndex("note_text");
            savedText = noteCursor.getString(noteColIndex);
        }
        mNoteText.setText(savedText);
    }
}